/*
 * Copyright 2009 Prime Technology.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.primefaces.optimus.auth;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.context.FacesContext;

import org.primefaces.optimus.util.Constants;

public abstract class AuthMap implements Map{
	
	 public Collection values() {return null;}
     public Object put(Object key, Object value) {return null;}
     public Set keySet() {return null;}
     public boolean isEmpty() {return false;}
     public int size() {return 0;}
     public void putAll(Map t) {}
     public void clear() {}
     public boolean containsValue(Object value) {return false;}
     public Object remove(Object key) {return null;  }
     public boolean containsKey(Object key) {return false;}
     public Set entrySet() {return null;}

     public abstract Object get(Object obj);
     
     protected AuthContext getAuthContext() {
    	 return (AuthContext) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get(Constants.AUTHCONTEXT_KEY);
     }
     
     protected String[] parseRoles(Object property) {
         String[] roles = ((String)property).split(",");
         for (int i = 0; i < roles.length; i++) {
             roles[i] = roles[i].trim();
         }
         return roles;
     }
}
